function [g, g_prev] = e_step(S, g, w, Coords, phiCoord, phiCov)
global g_N;

g_prev = g;
for n=1:g_N
    for s=1:S
        Cov = phiCov(:,:,s);
        g(n, s) = w(s)*mvnpdf(Coords(n, :), phiCoord(s, :), Cov)/ ...
            (w.'*mvnpdf(Coords(n, :), phiCoord(:, :), Cov));
    end
end

% FIXME:
g = g + 1e-8;

end